#!/usr/bin/python

import gdrivestore
import scanlocalfs
import gflags
import logging
import sys

FLAGS = gflags.FLAGS

gflags.DEFINE_enum('logging_level', 'INFO',
    ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
    'Set the level of logging detail.')

gflags.DEFINE_string('gdrive_collection', 'gsync backup',
                     'The collection name to use on gdrive')

def main(argv):
  try:
    argv = FLAGS(argv)
  except gflags.FlagsError, e:
    print '%s\\nUsage: %s ARGS\\n%s' % (e, argv[0], FLAGS)
    sys.exit(1)
  logging.getLogger().setLevel(getattr(logging, FLAGS.logging_level))
  if argv[1] == 'putdir':
    store = gdrivestore.GdriveStore(FLAGS.gdrive_collection)
    scanlocalfs.SyncDirectory(store, argv[2], argv[3])
  if argv[1] == 'getdir':
    store = gdrivestore.GdriveStore(FLAGS.gdrive_collection)
    scanlocalfs.RestoreSnapshot(store, argv[2], argv[3], int(argv[4]))
    


if __name__ == '__main__':
  main(sys.argv)
